package com.chaoyi.controller;

import org.apache.commons.io.IOUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;

/**
 * 富文本编辑器controller
 *
 * @author xuanqicheng
 * @create 2018-11-下午3:53
 */
//@Controller
//@RequestMapping("/ueditor")
//public class UeditorController {
//
//    @RequestMapping(value="/")
//    public void config(HttpServletRequest request, HttpServletResponse response) {
//        response.setContentType("application/json");
//        String rootPath = request.getSession().getServletContext().getRealPath("/");
//        try {
//            request.setCharacterEncoding("UTF-8");
//            response.setCharacterEncoding("UTF-8");
//            response.setContentType("application/json");
//            String action = request.getParameter("action");
//            if("config".equals(action)){
//                PrintWriter out = response.getWriter();
//                InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("config.json");
//                IOUtils.copy(inputStream,out,"UTF-8");
//            }
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//
//    }
//}
